<script src="js.js"></script>{extend name="public/base" /}

<!--尾部-->

<!--返回顶部-->
{block name="content"}
{__block__}
<script src="../../static/uedi/ueditor.config.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/uedi/ueditor.all.js" type="text/javascript" charset="utf-8"></script>
<div class="c-r right">
	<div class="label1">
		<div class="title">
			菜单管理
		</div>



		<div class="label-4">
			<div class="form" id="forms">
				<div class="breadcrumb">
									<span>
										<a href="#">菜单管理 </a>
										<span class="separator">/</span>
									</span>
									<span>
										<span>修改菜单</span>
									</span>
				</div>

				<form action="editinsert" method="post" enctype="multipart/form-data" class="form-2">
					<div><label class="ltxt">商品名称:</label><input type="text" name="name" id="" value="{$data.name}" /><span></span></div>
					<div class="txtname"><label class="">链表页图片:</label><img src="{$data.pic}"  style="width: 100px;height: 100px"/><span></span></div>
					<div><label class="ltxt">链表页图片:</label><input type="file" name="image" /><span></span></div>
					<div>
						<label class="ltxt">图片集:</label>
						<div class="img-box full">
							<section class=" img-section">
								<div class="z_photo upimg-div" >
									<section class="z_file fl">
										<img src="../../static/home/img/a11.png" tppabs="http://www.jq22.com/demo/imgUp201703281022/img/a11.png" class="add-img">
										<input type="file"  id="file" class="file" value="" accept="image/jpg,image/jpeg,image/png,image/bmp" multiple onchange="UpLoad(this)"/>
									</section>
									<div class="clear"></div>
								</div>
							</section>
						</div>
						<span></span>
					</div>
					<aside class="mask works-mask">
						<div class="mask-content">
							<p class="del-p">您确定要删除作品图片吗？</p>
							<p class="check-p"><span class="del-com wsdel-ok">确定</span><span class="wsdel-no">取消</span></p>
						</div>
					</aside>
					<div><label class="ltxt">库存:</label><input type="text" name="stock" id="" value="{$data.stock}" /><span></span></div>
					<div><label class="ltxt">单位:</label><input type="text" name="unit" id="" value="{$data.unit}" /><span></span></div>

					<div><label class="ltxt">某宝价/最高价:</label><input type="text" name="max_price" id="" value="{$data.max_price}" /><span></span></div>
					<div><label class="ltxt">最低价/售价:</label><input type="text" name="min_price" id="" value="{$data.min_price}" /><span></span></div>
					
					<div style="display: none">
						<label class="ltxt">运费计算:</label>
						<div class="radio radioa">
							{if condition="$data['freight_count'] eq 0"}
							<label><input type="radio" name="freight_count" id="" value="0" checked/>按重量计算</label>
							<label><input type="radio" name="freight_count" id="" value="1" />按件计算</label>
							{else/}
							<label><input type="radio" name="freight_count" id="" value="0"/>按重量计算</label>
							<label><input type="radio" name="freight_count" id="" value="1" checked/>按件计算</label>
							{/if}


						</div>
						<span></span>
					</div>
					<div style="display: none">
						<label class="ltxt">运费设置:</label>
						<div class="radio radios">
							<div class="div">

								<label><input type="radio" name="freight_unify" id="" value="0"/>统一邮费</label><div class="relative">
								<input type="text" name="unify_freight" id="" value="{$data.freight_unify}"/><i class="i"></i></div>
								<div class="clear">
								</div></div>
							<div class="div">
								<label><input type="radio" name="freight_unify" id="" value="2" />运费模板</label>

								<div>
									<div class="bor bor2 bor10">
										<div class="hide"></div>
										<span data-type = "{$data.freid}">{$data.title}</span><i></i>
										<ul style="display: none;">

										</ul>
									</div>
									<i></i>
								</div>
								<div class="clear"></div>
							</div>
							<div class="div" style="float: left;">
								<a class="btn-a open-win">运费计算规则</a>
								<a class="btn-a" href="freight">新建运费模板</a>
								<div class="clear"></div>
							</div>
						</div>
						<div class="clear"></div>
						<span></span>
					</div>
					<div><label class="ltxt">排序:</label><input type="text" name="sort" id="" value="{$data.sort}" /><span></span></div>
					{if condition="$data['recom'] eq 0"}
					<div><label class="ltxt">热销商品:</label><input type="checkbox" name="recom" value="{$data.recom}" class="recom" autocomplete="off"/><span></span></div>

					{else/}
					<div><label class="ltxt">热销商品:</label><input type="checkbox" name="recom" value="{$data.recom}" class="recom" autocomplete="off" checked="checked"/><span></span></div>

					{/if}
					{if condition="$data['special_offer'] eq 0"}
					<div><label class="ltxt">特价商品:</label><input type="checkbox" name="special_offer" value="{$data.special_offer}" class="special_offer" autocomplete="off" /><span></span></div>

					{else/}
					<div><label class="ltxt">特价商品:</label><input type="checkbox" name="special_offer" value="{$data.special_offer}" class="special_offer" autocomplete="off" checked="checked"/><span></span></div>

					{/if}

					
					<div><label >生产日期:</label><input type="text" name="yieldtime" id="" value="{$data.yieldtime}" /><span></span></div>
					<div><label >备注:</label><input type="text" name="content" id="" value="{$data.content}" /><span></span></div>
					
					<div><label></label><button class="btns btn-right subbtn">完成</button><button class="btns btn-right">返回</button></div>
					<div class="clear"></div>

					<input type="hidden" name="datatype_two" id="datatype_two" value="{$data.template}" />


					<input type="hidden" name="imgurl" id="imgurl" value="" />
					<input type="hidden" name="goodsid" id="goodsid" value="{$data.goodsid}" />
				</form>
			</div>

		</div>

	</div>
</div>
<div id="toup">
	<img src="../../static/home/img/toup.png"/>
</div>
<div id="wrap" class="wrap">
	<div class="wrap-body express">
		<div class="title">
			运费计算规则
		</div>
		<div class="wrap-con">
			<img src="../../static/home/img/e825205360d70e108d3bf994a30d56fb.jpg"/>
		</div>
		<span class="close-wrap close-win">×</span>
		<div class="clear">

		</div>
		<div class="wrap-btn">
			<span class="close-btn close-win">取消</span>
			<span class="next-btn close-win">确认</span>
		</div>
	</div>
</div>

<div id="wrap" class="wraps">
	<div class="wrap-body express">
		<div class="title">
			商品规格规则
		</div>
		<div class="wrap-con">
			<img src="../../static/home/img/specifications.png"/>
		</div>
		<span class="close-wrap close-win">×</span>
		<div class="clear">

		</div>
		<div class="wrap-btn">
			<span class="close-btn close-win">取消</span>
			<span class="next-btn close-win">确认</span>
		</div>
	</div>
</div>
<script src="../../static/home/js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/js.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/echarts.common.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/dateRange.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/monthPicker.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/home/js/img_yasuo.js" type="text/javascript" charset="utf-8"></script>


<script type="text/javascript">
	//页面加载  运费模板状态
	var radio_state = "<?php echo $data['aaxa']?>";

	$(".radios input[type='radio']").eq(radio_state).attr('checked','checked')
	if (radio_state == 0) {
		var Text = ".radios input[type='text']";
		var Select = "#forms form .bor10";
		$(Text).removeClass('act');
		$(Select).addClass('act');
		$(Select).find('.hide').hide();
	} else{
		var Text = ".radios input[type='text']";
		var Select = "#forms form .bor10";
		$(Select).removeClass('act');
		$(Select).find('.hide').show();
		$(Text).addClass('act');
		$(Select).find('.hide').show();
	}





	//加载图片
	$.ajax({
		type:"get",
		url:"__publicPath__/home/goods/editajax?id=" + "<?php echo $data['goodsid']?>",
		data: '',
		dataType: "json",
		success: function(data){
			for (var i = 0; i < data.length; i++) {
				var asd = "<section class='up-section fl 0'><span class='up-span'></span><img class='close-upimg' src='../../static/home/img/a7.png'  onclick='closeimg($(this))'><img class='up-img' src="+data[i]+"  /></section>"
				$(".upimg-div").prepend(asd)
			}
		},
		error:function(){
			//alert('失败')
		}
	});

	var ajaxurl = "__publicPath__/home/commtype/addajax.shtml";

	$(document).ready(function(e) {
		var ue = UE.getEditor('container');
		$('input').lc_switch();
	});
	// IOS开关取值
	$('body').delegate('.recom', 'lcs-statuschange', function() {
		var status = ($(this).is(':checked')) ? 'checked' : 'unchecked';
		if (status == 'checked'){
			$(".recom").val(1)
		} else{
			$(".recom").val(0)
		}

	});

	$('body').delegate('.special_offer', 'lcs-statuschange', function() {
		var status = ($(this).is(':checked')) ? 'checked' : 'unchecked';
		if (status == 'checked'){
			$(".special_offer").val(1)
		} else{
			$(".special_offer").val(0)
		}

	});




	$(".radios input[type='radio']").click(function(){
		var Text = ".radios input[type='text']"
		var Select = "#forms form .bor10"
		var Radio = $(this).val()
		if (Radio == 0) {
			$(Text).attr("disabled",false);
			$(Text).removeClass('act');
			$(Select).addClass('act');
			$(Select).find('.hide').show();
			$(".bor10 span").text('');
			$("#datatype_two").val('');

		} else{
			$(".radios input[name='unify_freight']").val('')
			$(Text).attr("disabled",true);
			$(Text).attr('class','act');
			$(Select).removeClass('act');
			$(Select).find('.hide').hide();
		}

	})

	var i=0;
	$(".Addinput").click(function(){
		i++
		var html = "<p><input type='text' name='' id='' value='' class='inpa'/><input type='text' name='' id='' value='' class='inpb'/><input type='text' name='' id='' value='' class='inpc'/><input type='text' name='' id='' value='' class='inpd'/><input type='text' name='' id='' value='' class='inpe'/><i></i></p>"
		$(".addinput").append(html);
	})

	$(document).on("click", ".addinput p i", function(){
		$(this).parent().remove()
	});


	var datas = new Array();      //创建数组
	datas[0] =""; 				  //赋值
	$(".subbtn").click(function(){
//        alert(123)
       $.ajax({
           method:'get',
           url:"{:url('Goods/editinsert')}",
           success:function (data) {
               if(data == 1)
                   console.log(123)
//               window.history.go(-1)
           },
           error:function(err){
               console.log(123)
           }
       })
		$("#caidan").prop('value','')
		var q1 = '.inpa';
		var q2 = '.inpb';
		var q3 = '.inpc';
		var q4 = '.inpd';
		var q5 = '.inpe';
		for (var i = 0; i < $(".addinput p").length; i++) {
			if ($(".addinput p").eq(i).find('input').val() !== ''){
				datas[i] = $(".addinput p").eq(i).find(q1).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q2).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q3).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q4).val()+"/*max*/"
				datas[i] += $(".addinput p").eq(i).find(q5).val()

			} else{
				alert('空')
			}

		}
		var dataarr = datas.join('/*/-/')
		$("#caidan").prop('value',datas)
		// 使用完数组再次清空数组
		for (var i = 0; i < datas.length; i++) {
			datas.splice(0,9999)
		}

	})



	var Ptid = "0";   //获取每级id
	var Level = "0";   //获取级别
	$(".bor6").unbind('click').bind('click',function(){
		$(".bor7 ul li").remove()
		//alert('-')
		var	are = '';
		$.ajax({
			type:"get",
			url:ajaxurl,
			data: '',
			dataType: "json",
			success: function(data){
				for (var i = 0; i < data.length; i++){      //一级分类
					are += "<li data-type="+data[i].ptid+">"+data[i].name+"</li>";
					Level = data[i].level
				}
				$(".bor6 ul").html('')
				$(".bor6 ul").append(are)
			},
			error:function(){
				alert('失败')
			}
		});
	})

	var Li;  				//一级索引
	var towLi;				//二级索引
	//二级分类
	$(document).on("click", ".bor6 ul li", function(){
		$(".bor7 ul li").remove()
		$(".bor7 span").text('请选择')
		$(".bor8 ul li").remove()
		$(".bor8 span").text('请选择')
		Li = $(this).index()
		var	are = '';
		$.ajax({
			type:"get",
			url:ajaxurl,
			data: '',
			dataType: "json",
			success: function(data){
				for (towLi = 0; towLi < data[Li].sub.length; towLi++) {   //二级菜单
					are += "<li data-type="+data[Li].sub[towLi].ptid+">"+data[Li].sub[towLi].name+"</li>"
					Level = data[Li].sub[towLi].level
				}
				$(".bor7 ul").html('')
				$(".bor7 ul").append(are)
			},
			error:function(){
				alert('失败')
			}
		});
	})

	//三级分类
	$(document).on("click", ".bor7 ul li", function(){
		$(".bor8 ul li").remove()
		$(".bor8 span").text('请选择')
		var stowLi = $(this).index()
		var	are = '';
		$.ajax({
			type:"get",
			url:ajaxurl,
			data: '',
			dataType: "json",
			success: function(data){
				for (var i = 0; i < data[Li].sub[stowLi].sub.length; i++) {   //三级菜单
					are += "<li data-type="+data[Li].sub[stowLi].sub[i].ptid+">"+data[Li].sub[stowLi].sub[i].name+"</li>"
					Level = data[Li].sub[stowLi].sub[i].level
				}
				$(".bor8 ul").html('')
				$(".bor8 ul").append(are)
				//console.log(Level)
			},
			error:function(){
				alert('失败')
			}
		});
	})



	$(".subbtn").click(function(){
		$("#menu").val();
		$("#imgurl").val('');
		if ($(".bor6 span").text() != "请选择"){
			Ptid = $(".bor6 span").attr('data-type')
			if ($(".bor7 span").text() != "请选择"){
				Ptid = $(".bor7 span").attr('data-type')
				if ($(".bor8 span").text() != "请选择"){
					Ptid = $(".bor8 span").attr('data-type')
				}
			}
		} else{
			return false
		}
		//console.log("级别："+Ptid+" 级数："+Level)
		$("#menu").val(Ptid)
		//获取图片路径
		var imgurl = '';						//图片存储URL地址
		var img = $(".up-section");
		for (var i = 0; i < img.length; i++) {
			imgurl += img.eq(i).find('.up-img').attr('src')+'_-_'
		}
		$("#imgurl").val(imgurl);

		console.log($("#imgurl").val())
		//return false;
	})
	//开始请求模板
	var ones_one = '';
	$.ajax({
		type:"get",
		url:'__publicPath__/home/goods/templateajax.shtml',
		data: '',
		dataType: "json",
		success: function(data){
			for (var i = 0; i < data.length; i++){
				if (data[i].unit == 0) {
					ones_one += "<li data-type="+data[i].freid+">"+data[i].title+"</li>"
					$(".bor10 ul").html('')
					$(".bor10 ul").append(ones_one)
				}

			}

		},
		error:function(){
			alert('失败')
		}
	});

	$("#forms form > div .radioa label").click(function(){
		var Index = $(this).index();
		console.log(Index)
		var ones = '';
		var twos = '';
		$.ajax({
			type:"get",
			url:'__publicPath__/home/goods/templateajax.shtml',
			data: '',
			dataType: "json",
			success: function(data){
				for (var i = 0; i < data.length; i++){
					if (Index == 0) {
						if (data[i].unit == 0) {
							ones += "<li data-type='0'>"+data[i].title+"</li>"
							$(".bor10 ul").html('')
							$(".bor10 ul").append(ones)
						}
					} if (Index == 1){
						if (data[i].unit == 1) {
							ones += "<li data-type="+data[i].freid+">"+data[i].title+"</li>"
							$(".bor10 ul").html('')
							$(".bor10 ul").append(ones)
						}
					}
				}

			},
			error:function(){
				alert('失败')
			}
		});
	})
</script>
{/block}

